﻿/*
 * simplyScroll 2 - a scroll-tastic jQuery plugin
 *
 * http://logicbox.net/jquery/simplyscroll/
 *
 * Copyright (c) 2009-2012 Will Kelly - http://logicbox.net
 *
 * Dual licensed under the MIT and GPL licenses.
 *
 * Version: 2.0.5 Last revised: 10/05/2012
 *
 */
(function (c, j, i) {
    c.fn.simplyScroll = function (a) { return this.each(function () { new c.simplyScroll(this, a) }) }; var h = { customClass: "simply-scroll", frameRate: 24, speed: 1, orientation: "horizontal", auto: !0, autoMode: "loop", manualMode: "end", direction: "forwards", pauseOnHover: !0, pauseOnTouch: !0, pauseButton: !1, startOnLoad: !1 }; c.simplyScroll = function (a, b) {
        var g = this; this.o = c.extend({}, h, b || {}); this.isAuto = !1 !== this.o.auto && null !== this.o.autoMode.match(/^loop|bounce$/); this.isRTL = (this.isHorizontal = null !== this.o.orientation.match(/^horizontal|vertical$/) &&
        this.o.orientation == h.orientation) && "rtl" == c("html").attr("dir"); this.isForwards = !this.isAuto || this.isAuto && (null !== this.o.direction.match(/^forwards|backwards$/) && this.o.direction == h.direction) && !this.isRTL; this.isLoop = this.isAuto && "loop" == this.o.autoMode || !this.isAuto && "loop" == this.o.manualMode; this.events = (this.supportsTouch = "createTouch" in document) ? { start: "touchstart MozTouchDown", move: "touchmove MozTouchMove", end: "touchend touchcancel MozTouchRelease" } : { start: "mouseenter", end: "mouseleave" };
        this.$list = c(a); var d = this.$list.children(); this.$list.addClass("simply-scroll-list").wrap('<div class="simply-scroll-clip"></div>').parent().wrap('<div class="' + this.o.customClass + ' simply-scroll-container"></div>'); this.isAuto ? this.o.pauseButton && (this.$list.parent().parent().prepend('<div class="simply-scroll-btn simply-scroll-btn-pause"></div>'), this.o.pauseOnHover = !1) : this.$list.parent().parent().prepend('<div class="simply-scroll-forward"></div>').prepend('<div class="simply-scroll-back"></div>');
        if (1 < d.length) { var f = !1, e = 0; this.isHorizontal ? (d.each(function () { e = e + c(this).outerWidth(true) }), f = d.eq(0).outerWidth(!0) * d.length !== e) : (d.each(function () { e = e + c(this).outerHeight(true) }), f = d.eq(0).outerHeight(!0) * d.length !== e); f && (this.$list = this.$list.wrap("<div></div>").parent().addClass("simply-scroll-list"), this.isHorizontal ? this.$list.children().css({ "float": "left", width: e + "px" }) : this.$list.children().css({ height: e + "px" })) } this.o.startOnLoad ? c(j).load(function () { g.init() }) : this.init()
    }; c.simplyScroll.fn =
    c.simplyScroll.prototype = {}; c.simplyScroll.fn.extend = c.simplyScroll.extend = c.extend; c.simplyScroll.fn.extend({
        init: function () {
            this.$items = this.$list.children(); this.$clip = this.$list.parent(); this.$container = this.$clip.parent(); this.$btnBack = c(".simply-scroll-back", this.$container); this.$btnForward = c(".simply-scroll-forward", this.$container); this.isHorizontal ? (this.itemMax = this.$items.eq(0).outerWidth(!0), this.clipMax = this.$clip.width(), this.dimension = "width", this.moveBackClass = "simply-scroll-btn-left",
            this.moveForwardClass = "simply-scroll-btn-right", this.scrollPos = "Left") : (this.itemMax = this.$items.eq(0).outerHeight(!0), this.clipMax = this.$clip.height(), this.dimension = "height", this.moveBackClass = "simply-scroll-btn-up", this.moveForwardClass = "simply-scroll-btn-down", this.scrollPos = "Top"); this.posMin = 0; this.posMax = this.$items.length * this.itemMax; var a = Math.ceil(this.clipMax / this.itemMax); if (this.isAuto && "loop" == this.o.autoMode) this.$list.css(this.dimension, this.posMax + this.itemMax * a + "px"), this.posMax +=
            this.clipMax - this.o.speed, this.isForwards ? (this.$items.slice(0, a).clone(!0).appendTo(this.$list), this.resetPosition = 0) : (this.$items.slice(-a).clone(!0).prependTo(this.$list), this.resetPosition = this.$items.length * this.itemMax, this.isRTL && (this.$clip[0].dir = "ltr", this.$items.css("float", "right"))); else if (!this.isAuto && "loop" == this.o.manualMode) {
                this.posMax += this.itemMax * a; this.$list.css(this.dimension, this.posMax + this.itemMax * a + "px"); this.posMax += this.clipMax - this.o.speed; this.$items.slice(0, a).clone(!0).appendTo(this.$list);
                this.$items.slice(-a).clone(!0).prependTo(this.$list); this.resetPositionForwards = this.resetPosition = a * this.itemMax; this.resetPositionBackwards = this.$items.length * this.itemMax; var b = this; this.$btnBack.bind(this.events.start, function () { b.isForwards = false; b.resetPosition = b.resetPositionBackwards }); this.$btnForward.bind(this.events.start, function () { b.isForwards = true; b.resetPosition = b.resetPositionForwards })
            } else this.$list.css(this.dimension, this.posMax + "px"), this.isForwards ? this.resetPosition = 0 : (this.resetPosition =
            this.$items.length * this.itemMax, this.isRTL && (this.$clip[0].dir = "ltr", this.$items.css("float", "right"))); this.resetPos(); this.interval = null; this.intervalDelay = Math.floor(1E3 / this.o.frameRate); if (this.isAuto || "end" != this.o.manualMode) for (; 0 !== this.itemMax % this.o.speed;) if (this.o.speed--, 0 === this.o.speed) { this.o.speed = 1; break } b = this; this.trigger = null; this.funcMoveBack = function (a) {
                a !== i && a.preventDefault(); b.trigger = !b.isAuto && b.o.manualMode == "end" ? this : null; b.isAuto ? b.isForwards ? b.moveBack() : b.moveForward() :
                b.moveBack()
            }; this.funcMoveForward = function (a) { a !== i && a.preventDefault(); b.trigger = !b.isAuto && b.o.manualMode == "end" ? this : null; b.isAuto ? b.isForwards ? b.moveForward() : b.moveBack() : b.moveForward() }; this.funcMovePause = function () { b.movePause() }; this.funcMoveStop = function () { b.moveStop() }; this.funcMoveResume = function () { b.moveResume() }; if (this.isAuto) {
                this.paused = !1; var g = function () { if (b.paused === false) { b.paused = true; b.funcMovePause() } else { b.paused = false; b.funcMoveResume() } return b.paused }; this.supportsTouch &&
                this.$items.find("a").length && (this.supportsTouch = !1); if (this.isAuto && this.o.pauseOnHover && !this.supportsTouch) this.$clip.bind(this.events.start, this.funcMovePause).bind(this.events.end, this.funcMoveResume); else if (this.isAuto && this.o.pauseOnTouch && !this.o.pauseButton && this.supportsTouch) {
                    var d, f; this.$clip.bind(this.events.start, function (a) { g(); var c = a.originalEvent.touches[0]; d = b.isHorizontal ? c.pageX : c.pageY; f = b.$clip[0]["scroll" + b.scrollPos]; a.stopPropagation(); a.preventDefault() }).bind(this.events.move,
                    function (a) { a.stopPropagation(); a.preventDefault(); a = a.originalEvent.touches[0]; a = d - (b.isHorizontal ? a.pageX : a.pageY) + f; if (a < 0) a = 0; else if (a > b.posMax) a = b.posMax; b.$clip[0]["scroll" + b.scrollPos] = a; b.funcMovePause(); b.paused = true })
                } else this.o.pauseButton && (this.$btnPause = c(".simply-scroll-btn-pause", this.$container).bind("click", function (a) { a.preventDefault(); g() ? c(this).addClass("active") : c(this).removeClass("active") })); this.funcMoveForward()
            } else this.$btnBack.addClass("simply-scroll-btn " + this.moveBackClass).bind(this.events.start,
            this.funcMoveBack).bind(this.events.end, this.funcMoveStop), this.$btnForward.addClass("simply-scroll-btn " + this.moveForwardClass).bind(this.events.start, this.funcMoveForward).bind(this.events.end, this.funcMoveStop), "end" == this.o.manualMode && (!this.isRTL ? this.$btnBack.addClass("disabled") : this.$btnForward.addClass("disabled"))
        }, moveForward: function () {
            var a = this; this.movement = "forward"; null !== this.trigger && this.$btnBack.removeClass("disabled"); a.interval = setInterval(function () {
                a.$clip[0]["scroll" + a.scrollPos] <
                a.posMax - a.clipMax ? a.$clip[0]["scroll" + a.scrollPos] += a.o.speed : a.isLoop ? a.resetPos() : a.moveStop(a.movement)
            }, a.intervalDelay)
        }, moveBack: function () { var a = this; this.movement = "back"; null !== this.trigger && this.$btnForward.removeClass("disabled"); a.interval = setInterval(function () { a.$clip[0]["scroll" + a.scrollPos] > a.posMin ? a.$clip[0]["scroll" + a.scrollPos] -= a.o.speed : a.isLoop ? a.resetPos() : a.moveStop(a.movement) }, a.intervalDelay) }, movePause: function () { clearInterval(this.interval) }, moveStop: function (a) {
            this.movePause();
            null !== this.trigger && ("undefined" !== typeof a && c(this.trigger).addClass("disabled"), this.trigger = null); this.isAuto && "bounce" == this.o.autoMode && ("forward" == a ? this.moveBack() : this.moveForward())
        }, moveResume: function () { "forward" == this.movement ? this.moveForward() : this.moveBack() }, resetPos: function () { this.$clip[0]["scroll" + this.scrollPos] = this.resetPosition }
    })
})(jQuery, window);